precision lowp float;
varying vec4 vColor;				
varying vec2 vTextureCoord;					
uniform sampler2D uSampler;								

vec4 old(vec4 color){
	float r = 0.393 * color.r + 0.769 * color.g + 0.189 * color.b; 
	float g = 0.349 * color.r + 0.686 * color.g + 0.168 * color.b; 
	float b = 0.272 * color.r + 0.534 * color.g + 0.131 * color.b;
	return vec4(r,g,b,color.a);
}

vec3 yuv(vec3 color){
	float R = color.r * 255.0;
	float G = color.g * 255.0;
	float B = color.b * 255.0;
	float Y = 0.299 * R + 0.587 * G + 0.114 * B;
	float U = -0.1687 * R - 0.3313 * G + 0.5 * B + 128.0;
	float V = 0.5 * R - 0.4187 * G - 0.0813 * B + 128.0;
	return vec3(Y,U,V);
}

vec3 rgb(vec3 color){
	float Y = color.r;
	float U = color.g;
	float V = color.b;
    float R = Y + 1.13983 * (V-128.0);
    float G = Y - 0.39465 * (U-128.0) - 0.58060 * (V-128.0);
    float B = Y + 2.03211 * (U-128.0);
	return vec3(R,G,B);
}

void main(void) {
    vec4 c = texture2D(uSampler, vTextureCoord);
	vec3 c2 = yuv(c.xyz);
	c2.r *= 0.8;
	// c2.g *= 0.8;
	// c2.b *= 0.8;
	vec3 c3 = rgb(c2);
	gl_FragColor = vec4(c3.xyz/255.0,c.a);
}

